<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		  content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no"/>
	<meta name="format-detection" content="email=no"/>
	<title>邀请好友</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/normalize1.css"/>
	<script type="text/javascript" src="//res.cdn.openinstall.io/openinstall.js"></script>
	<script type="text/javascript">
        (function () {
            //设置页面的rem大小
            document.addEventListener('DOMContentLoaded', function () {
                var html = document.documentElement;
                var windowWidth = html.clientWidth;
                html.style.fontSize = windowWidth /7.5 + 'px';
            }, false);
            window.onresize = function(){
                var html = document.documentElement;
                var windowWidth = html.clientWidth;
                html.style.fontSize = windowWidth /7.5 + 'px';
            };
        })();
	</script>
	<script type="text/javascript" src="//res.cdn.openinstall.io/openinstall.js"></script>
    <style type="text/css">
        .send_reg{
            display: block;
            text-align: center;
            line-height: .9rem;
        }
        .inviteBox_textBox li{
            color: #fff;
            font-size: .32rem;
            font-weight: 500;
            margin-bottom: .6rem;
        }
        .inviteBox_textBox li i{
            font-style: normal;
            display: inline-block;
            background: #fff;
            color: #ff454a;
            font-size: .3rem;
            width: .32rem;
            height: .32rem;
            text-align: center;
            line-height: .3rem;
            border-radius: .32rem;
            margin-right: .1rem;
            margin-left: .1rem;
        }
        .inviteBox_textBox li em{
            font-size: .6rem;
            font-style: normal;
        }
    </style>
</head>
<body>
<div class="inviteBox">
	<div class="inviteBox_form">

		<ul class="inviteBox_textBox">
            <li><i>1</i>在线填写申请资料  最快<em>3</em>分钟</li>
            <li><i>2</i>快速处理通过审核  最快<em>1</em>分钟</li>
            <li><i>3</i>极速放款资金到账  最快<em>1</em>秒钟</li>
        </ul>
        <a href="###"  id="downloadButton" class="send_reg">立即下载</a>
	</div>
</div>
<input name="invited_code" type="hidden" value="{$invited_code}">
<script type="text/javascript">
    //初始化
	/*web页面向app传递的json数据(json string/js Object)，应用被拉起或是首次安装时，通过相
	 应的android/ios api可以获取此数据*/
    var n_tid = document.getElementsByName("invited_code")[0].value;
        var d = '{\"invited_code\":\"'+n_tid+'\"}';

    var m = new OpenInstall({
		/*appKey必选参数，openinstall为每个应用分配的ID*/
        appKey : 'i5jb28'
    }, d);
//    	alert(d);
    //用法1：如app已安装，进入网页立即拉起app；用户点击某个按钮时再开始安装app
	/*通过scheme拉起app(如果已在openinstall平台开启scheme启动功能)*/
      m.schemeWakeup();
	/*用户点击某个按钮时，安装app*/
    document.getElementById('downloadButton').onclick=function(){
        m.install();
//        document.getElementById('downloadButton').onclick=function(){
        //   //500毫秒后app尚未拉起，将安装app，可自定义时间
//           m.wakeupOrInstall({timeout:500});
    }

</script>

<script src="__PUBLIC__/js/zepto1.js"></script>
<script type="text/javascript">
    function submitReg(){
        var mobile = $("input[name='mobile']").val();
        var pwd = $("input[name='pwd']").val();
        var code = $("input[name='code']").val();
        if(mobile == null || mobile == ''){
            alertBottom("手机号码格式有误！")
            return false;
        }
        if(pwd.length < 6 || pwd.length >16 || pwd == null || pwd==''){
            alertBottom("密码长度应在6-16字符之间");
            return false;
        }
        if(code == null || code == ''){
            alertBottom("验证码不得为空！")
            return false;
        }

        //执行注册提交操作
        $.post(
            "https://yapi.miaodaoxj.com/Account/register",
            {
                mobile:mobile,
                pwd:pwd,
                code:code,
            },function(data){
                ret = JSON.parse(data);
                if(ret['ret'] == 1001 ){
                    //注册成功
                    alertBottom(ret['code']);
                    setTimeout(function() {
                        window.location.href="";//跳转地址
                    },100)

                }else{
                    //注册失败
                    alertBottom(ret['code']);
                }
            }
        )

    }
    function sendcode(obj){
        var mobile = $("input[name='mobile']").val();
        if(!(/^1(3|4|5|7|8)\d{9}$/.test(mobile))){
            alertBottom("手机号码格式有误！")
            return false;
        }else{
            //手机号码无误 验证号码是否已注册，如果未注册则发送短信并调用settime(obj) 倒计时函数;
            $.post(
                "https://yapi.miaodaoxj.com/Account/getcode",
                {
                    type:2,
                    mobile:mobile,

                },function(data){
                    ret = JSON.parse(data);
                    if(ret['ret'] == 1001 ){
                        alertBottom(ret['code']);
                        settime(obj);
                    }else{
                        alertBottom(ret['code']);
                    }
                }
            )

        }
    }

    //倒计时
    var countdown=60; //倒计时秒数
    function settime(obj){
        if (countdown == 0) {
            obj.removeAttribute("disabled");
            obj.value="获取验证码";
            countdown = 60;
            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value = countdown + "s";
            countdown--;
        }
        setTimeout(function() {
                settime(obj) }
            ,1000)
    }

    //===============底部弹出框
    function alertBottom(str) {
        var div=document.createElement('div');
        div.innerHTML='<span class="m-botAlert-con">' + str + ' </span>';
        div.className='m-botAlert';
        div.id='botAlert';
        document.body.appendChild(div);
        setTimeout(function () {
            div.className='m-botAlert alert-hide'
        }, 3000);
        setTimeout(function () {
            document.body.removeChild(div);
        }, 5000);
    }



</script>
</body>
</html>